package com.anti.modular.bus.roomfurniture.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.bus.roomfurniture.param.RoomFurnitureParam;
import com.anti.modular.bus.roomfurniture.service.RoomFurnitureService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 房间家私配置表控制器
 *
 * @author anti
 * @date 2021-04-18 17:08:44
 */
@RestController
@RequestMapping("roomFurniture")
public class RoomFurnitureController {

    @Resource
    private RoomFurnitureService roomFurnitureService;

    /**
     * 查询房间家私配置表
     *
     * @author anti
     * @date 2021-04-18 17:08:44
     */
    @GetMapping("page")
    @BusinessLog(title = "房间家私配置表_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public Result page(PageParam pageParam, RoomFurnitureParam roomFurnitureParam) {
        return Result.data(roomFurnitureService.page(pageParam,roomFurnitureParam));
    }

    /**
     * 添加房间家私配置表
     *
     * @author anti
     * @date 2021-04-18 17:08:44
     */
    @Permission
    @PostMapping("add")
    @BusinessLog(title = "房间家私配置表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(RoomFurnitureParam.add.class) RoomFurnitureParam roomFurnitureParam) {
            roomFurnitureService.add(roomFurnitureParam);
        return Result.success("新增成功");
    }

    /**
     * 删除房间家私配置表
     *
     * @author anti
     * @date 2021-04-18 17:08:44
     */
    @Permission
    @PostMapping("delete")
    @BusinessLog(title = "房间家私配置表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@RequestBody @Validated(RoomFurnitureParam.delete.class) RoomFurnitureParam roomFurnitureParam) {
            roomFurnitureService.delete(roomFurnitureParam);
        return Result.success("删除成功");
    }

    /**
     * 编辑房间家私配置表
     *
     * @author anti
     * @date 2021-04-18 17:08:44
     */
    @Permission
    @PostMapping("edit")
    @BusinessLog(title = "房间家私配置表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(RoomFurnitureParam.edit.class) RoomFurnitureParam roomFurnitureParam) {
            roomFurnitureService.edit(roomFurnitureParam);
        return Result.success("修改成功");
    }

    /**
     * 查看房间家私配置表
     *
     * @author anti
     * @date 2021-04-18 17:08:44
     */
    @GetMapping("detail")
    @BusinessLog(title = "房间家私配置表_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    public Result detail(@Validated(RoomFurnitureParam.detail.class) RoomFurnitureParam roomFurnitureParam) {
        return Result.data(roomFurnitureService.detail(roomFurnitureParam));
    }

    /**
     * 房间家私配置表列表
     *
     * @author anti
     * @date 2021-04-18 17:08:44
     */
    @GetMapping("list")
    @BusinessLog(title = "房间家私配置表_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    public Result list(RoomFurnitureParam roomFurnitureParam) {
        return Result.data(roomFurnitureService.list(roomFurnitureParam));
    }

    @GetMapping("getRoomFurnitureListByRoomId/{roomId}")
    public Result getRoomFurnitureListByRoomId(@PathVariable(name = "roomId") Long roomId) {
        return Result.data(roomFurnitureService.getRoomFurnitureListByRoomId(roomId));
    }

    @GetMapping("getRoomFurnitureListByLeaseId/{leaseId}")
    public Result getRoomFurnitureListByLeaseId(@PathVariable(name = "leaseId") Long leaseId) {
        return Result.data(roomFurnitureService.getRoomFurnitureListByLeaseId(leaseId));
    }
}
